home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 8 / Power CD-ROM 8.iso / prgmming / pent_tst / pent_tst.c next >
Encoding:
C/C++ Source or Header  |  1994-12-03  |  2.0 KB  |  63 lines

  1. #pragma page(1)
  2. #define LINT_ARGS
  3. #define INCL_DOS
  4. #define INCL_VIO
  5. #define DLL
  6.  
  7. /********************************/
  8. /* Include System Library Stuff */
  9. /********************************/
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <stdlib.h>
  13. #include <math.h>
  14.  
  15.  
  16. void main()
  17. /************************************************************************/
  18. /* Program to show presence of Intel Pentium Floating Point Divide Bug  */
  19. /*                                                                      */
  20. /*   Based on C++ program from  phaniraj@badlands.nodak.edu             */
  21. /*                                                                      */
  22. /************************************************************************/
  23. {  /* main */
  24. double x,y,z;
  25.  
  26.    /****************************/
  27.    /* Set up division          */
  28.    /****************************/
  29.  
  30.    x = 4195835.0;
  31.    y = 3145727.0;
  32.  
  33.    /********************************************************************/
  34.    /* The correct answer is 1.333 820 449 136 241. Bad Pentiums'll     */
  35.    /* 1.333 739 068 902 038. That's wrong.                             */
  36.    /* Divide x by y                                                    */
  37.    /********************************************************************/
  38.  
  39.    z = x - (x / y) * y;
  40.  
  41.    if ( fabs(z) >= 1.e-1)
  42.    {
  43.       printf(" This CPU has the FDIV bug\n\n");
  44.       printf("    4195835 / 3145727 should equal 1.333820449136241\n");
  45.       printf("       while your processor yields %16.15f\n", (x/y));
  46.    }
  47.    else
  48.       printf("This processor is mercifully free from the FDIV bug\n");
  49.  
  50.  
  51.    /********************************************************************/
  52.    /* Some more examples                                               */
  53.    /********************************************************************/
  54.  
  55.    printf("\n");
  56.  
  57.    x = 824633702449.0;
  58.    printf("%f should be zero\n", x - (1.0/x)*x*x);
  59.  
  60.  
  61.    return;
  62. } /* main */
  63.